/**
 * 
 */
function userlogin() {
	var name = $('#username').val();
	var pass = $('#password').val();
	if (name != '' && pass != '') {
		var url = "login.php?a=dologin";
		var data = "username=" + name + "&password=" + pass;
		$.ajax({
			  type: 'POST',
			  url: url,
			  data: data,
			  success: loginCallback,
			  dataType: 'json'
			});
	} else {
		alert('用户名和密码不能为空!')
	}
	return false;
}

function loginCallback(data) {
	var result = data;
    if (typeof(result) == 'object') {
        alert(result.message);
    } else {
        alert(result);
    }
}

(function() {
	jQuery(document).ready(function($){
		$("#login-submit").click(userlogin);
	});
})();